package itman.springcloud.utils;

import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class CommonUtil {

    public static String chageEncode2GBK(String source){
        String str = "";
        try {
            str = new String(source.getBytes("ISO-8859-1"),"GBK");
        } catch (UnsupportedEncodingException e) {
            System.out.println("编码转换失败！");
            e.printStackTrace();
        }
        return str;
    }

    public static String getCurrentDate() {
        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        return simpleDateFormat.format(date);
    }

    public static String getCurrentDateTime() {
        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return simpleDateFormat.format(date);
    }

}
